HAOJX

nginx中的keepalive , 共享内存

字数统计: 115阅读时长: 1 min
2018/10/15 Share

对上游服务使用keepalive

对上游连接的http头部设置

1
2
proxy_http_version 1.1;
proxy_set_header Connection "";

指令:

1
2
3
Syntax:  keepalive connections;
Default: —
Context: upstream

指定上游服务器域名解析

1
2
3
4
5
6
7
Syntax:  resolver address ... [valid=time] [ipv6=on|off];
Default: —
Context: http, server, location

Syntax: resolver_timeout time;
Default: resolver_timeout 30s;
Context: http, server, location

共享内存

1
2
3
Syntax:  zone name [size];
Default: —
Context: upstream

分配出共享内存 , 将upstream定义的策略和上游服务的状态数据放到共享内存中, 对所有worker都生效

CATALOG
  1. 1. 对上游服务使用keepalive
  2. 2. 指定上游服务器域名解析
  3. 3. 共享内存